<?php
include("./config.php");
include("./utils.php");
checkLogin();
?>
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>编辑</title>
  <?php include 'scripts-inc.php' ?>

  <script>
  var gData={};
  var id = <?php echo $_GET["id"]; ?>;
  var userid = <?php echo $_GET["userid"]; ?>;
  $(function(){
    var u = 'query.php?op=one-item&userid='+userid+'&id='+id;
    $.ajax({url:u,
      dataType:"json",
      async:true,
      success : function(msg, textStatus) { 
        var data = msg[0];
        if(data){
          $("#tname").val(data["name"]);
          $("#turl").val(data["url"]);
          $("#tcate").val(data["category"]);
          $("#tdesc").val(data["desc"]);
          $("#tappe").val(data["appearance"]);
          $("#tmode").val(data["mode"]);
          gData = data;
        }
      }
    },"text");

    $("#del-item").click(function(){
      var data = {
        userid:userid,
        id:id,
        op:'del-item'
      };

      $("#content").text("提交中...");
      $.post("update-data.php", data, function(msg){
        $("#content").text("已经删除");
        show_msg(msg + "\n删除成功");
        $("#back").text("返回首页");
        $("#del-item").hide();
      });
    });

  });//end of $(function(){

  </script>
</head>
<body>
<!-- template -->
<!-- end of template -->


<div id="wrapper">
<div id="container">
<!-- .................................................... -->

<div id="nav_data_src">
    <?php include 'navbars-inc.php' ?>
</div>

<div id="tcontainer" class="center">
<div>
    <div class="form-group row">
      <label for="tname" class="col-sm-1 control-label">标题</label>
      <div class="col-sm-5">
        <input type="" class="form-control" id="tname" name="tname" placeholder="标题" disabled>
      </div>
    </div>

    <div class="form-group row">
      <label for="turl" class="col-sm-1 control-label">网址</label>
      <div class="col-sm-5">
        <input type="" class="form-control" id="turl" name="turl" placeholder="URL网址" disabled>
      </div>
    </div>


    <div class="form-group row">
      <label for="tcate" class="col-sm-1 control-label">类别</label>
      <div class="col-sm-5">
        <input type="" class="form-control" id="tcate" name="tcate" placeholder="类别1-5" disabled>
      </div>
    </div>
    <div class="form-group row">
      <label for="tappe" class="col-sm-1 control-label">外观</label>
      <div class="col-sm-5">
        <input type="" class="form-control" id="tappe" name="tappe" placeholder="外观1-4" disabled>
      </div>
    </div>
    <div class="form-group row">
      <label for="tmode" class="col-sm-1 control-label">模式</label>
      <div class="col-sm-5">
        <input type="" class="form-control" id="tmode" name="tmode" placeholder="模式0-1" disabled>
      </div>
    </div>
    <div class="form-group row">
      <label for="tdesc" class="col-sm-1 control-label">说明</label>
      <div class="col-sm-5">
        <textarea class="form-control" id="tdesc" rows="5" name="tdesc" placeholder="对这个网址的介绍" disabled></textarea>
      </div>
    </div>

  <div class="clearfix"></div>
  <div class="form-group row">
    <div class="col-sm-2 col-sm-offset-1 text-center">
      <a href="./show-app.php" class="btn btn-lg btn-success btn-center" id="back">取消返回</a>
    </div>
    <div class="col-sm-2 text-center">
      <button type="submit" class="btn btn-lg btn-danger" id="del-item">确认删除</button>
    </div>
  </div>
</div>


</div> <!-- end of tcontainer -->

<div id="content">
</div><!-- end of content -->

<!-- .................................................... -->
</div><!-- end of container -->
</div><!-- end of wrapper -->
</body>
</html>
